package com.brucekong.slm.service.forum;

import com.brucekong.slm.mapper.forum.ForumMapper;
import com.brucekong.slm.model.forum.ForumDomain;
import com.brucekong.slm.model.forum.ReplyDomain;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.List;

@Service
public class ForumService {

    @Resource
    private ForumMapper forumMapper;

    public PageInfo<ForumDomain> getForumList(int page, int limit) {
        PageHelper.startPage(page, limit);
        List<ForumDomain> forumDomainList = forumMapper.getForumList(page, limit);
        // 需要把时间转换为格式化的
        return new PageInfo<>(forumDomainList);
    }

    public PageInfo<ReplyDomain> getReplyList(int page, int limit) {
        PageHelper.startPage(page, limit);
        List<ReplyDomain> replyDomainList = forumMapper.getReplyList(page, limit);
        return new PageInfo<>(replyDomainList);
    }
}